package com.hw.paltfrom.controller.system;

import java.util.Map;

/**
 *角色权限绑定
 * 曹荣坤
 * 2019年11月6日15:06:04
 */

import com.hw.paltfrom.utils.ResponeResultUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hw.paltfrom.pack.ResponseResult;
import com.hw.paltfrom.rescode.HWSystemCode;
import com.hw.paltfrom.service.system.BaseAuthorizeServer;
import com.hw.paltfrom.utils.VerifyUtil;
import com.hw.paltfrom.vo.BaseAuthorizeVo;

@RestController
@RequestMapping(value = "/authorize")
public class BaseAuthorizeController {
	
	@Autowired
	private BaseAuthorizeServer baseAuthorizeServer;
	
//	给角色添加权限
	@RequestMapping(value = "/insert")
	public Map<String, Object> insert(BaseAuthorizeVo vo){
		Boolean verify = VerifyUtil.verifyParams(vo);
		if (!verify){
			return ResponeResultUtil.fail(HWSystemCode.PARAMS_ERROR);
		}

		return baseAuthorizeServer.insert(vo);

	}

//	查询该角色的权限
	@RequestMapping(value = "/findAll")
	public Map<String, Object> query(String fRoleid) {
		Boolean flag = StringUtils.isBlank(fRoleid);
		if (flag) {
			return ResponseResult.fail(HWSystemCode.PARAMS_ERROR);
		}
		return baseAuthorizeServer.queryAllList(fRoleid);
	}
}
